
/**
** \file       free_rules.c
**
** \brief      this function parse the if rule
**
** \author     Ben M'rad Hanna, Laterem Hamza, Boillot Ulysse, De Olivera
**             Guillaume and Nguyen Viet Dung
**
** \version    0.8
**
** \date       26 Novembre 2010
**
*/

#include "free_parser.h"

static void     free_elseclause(struct else_clause      *rec)
{
  if (rec != NULL)
  {
    free_cmpdlist(rec->in_if);
    free_cmpdlist(rec->in_then);
    free_cmpdlist(rec->in_else);
    free_elseclause(rec->else_clause);
  }

  free(rec);
}

void		free_ruleif(s_ruleif		*ruleif)
{
  if (ruleif != NULL)
    {
      free_cmpdlist(ruleif->in_if);
      free_cmpdlist(ruleif->in_then);
      free_elseclause(ruleif->else_clause);
    }

  free(ruleif);
}

void		free_rulefor(s_rulefor		*rulefor)
{
  if (rulefor != NULL)
  {
    free_dogroup(rulefor->in_do);
  }

  free(rulefor);
}

void		free_ruleuntil(s_ruleuntil	*ruleuntil)
{
  if (ruleuntil != NULL)
  {
    free_dogroup(ruleuntil->in_do);
    free_cmpdlist(ruleuntil->in_until);
  }

  free(ruleuntil);
}

void		free_rulecase(s_rulecase	*rulecase)
{
  if (rulecase != NULL)
    free(rulecase);
}

void		free_rulewhile(s_rulewhile	*rulewhile)
{
  if (rulewhile != NULL)
    {
      free_dogroup(rulewhile->in_do);
      free_cmpdlist(rulewhile->in_while);
    }

  free(rulewhile);
}
